﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="send.aspx.cs" Inherits="JumbotCms.WebFile.Admin._mail_send" %>
<%@ Register assembly="Jumbot.Control" namespace="Jumbot.Control" tagprefix="Jumbot" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title></title>
<link type="text/css" rel="stylesheet" href="../../admin/otherpage/styles/common.css" />
<script type="text/javascript" src="../../_data/SysConfig.js"></script>
<script type="text/javascript" src="../../_libs/jquery-min.js"></script>
<script type="text/javascript" src="../../_libs/jquery.form.js"></script>
<script type="text/javascript" src="../../scripts/jumbotcms.js?v4"></script>
<link type="text/css" rel="stylesheet" href="../../style/global.css" />
<link type="text/css" rel="stylesheet" href="../../_libs/jquery.formvalidator/style.css" />
<script type="text/javascript" src="../../_libs/jquery.formvalidator.js"></script>

<script type="text/javascript">
(function(){
	$(document).ready(function(){
		$('#sendmailForm').ajaxForm({
			beforeSubmit: JumbotCms.AjaxFormSubmit,
			success :function(data){
				top.JumbotCms.Eval(data);
			}
		}); 
        	$.formValidator.initConfig({onError:function(msg){}});
        	$("#txtToMailList").formValidator({tipid:"tipToMailList",onshow:"多个地址用,隔开",onfocus:"多个地址用,隔开",oncorrect:"",defaultvalue:""}).RegexValidator({regexp:"emailgroup",datatype:"enum",onerror:"有格式不正确的邮箱"});
        	$("#txtTitle").formValidator({tipid:"tipTitle",onshow:"请输入邮件标题",onfocus:"请输入邮件标题",oncorrect:""}).InputValidator({min:6,max:50,onerror:"6-50字符"});
	});
	//Form验证
	JumbotCms.AjaxFormSubmit=function(item){
		try{
			if(jQuery.formValidator.PageIsValid('1'))
			{
				top.JumbotCms.Loading.show("正在发送,过程可能比较缓慢...");
				return true;
			}else{
				return false;
			}
		}catch(e){
			return false;
		}
	};
})();
function FormatMailList(id)
{
	var _val = $('#'+id).val();
	_val =_val.replace(/\r\n/g,"\\n");
	_val =_val.replace(/[,\n]+/g,",");
	_val =_val.replace(/[\n]+/g,",");
	_val =_val.replace(/[,]+/g,",");
	_val =_val.replace(/ /g,"");
	$('#'+id).val(_val);
}
    </script>
<script type="text/javascript">
function chkPost()
{
    if(jQuery.formValidator.PageIsValid('1'))
        ajaxSendMail();
}
function ajaxSendMail()
{
	top.JumbotCms.Loading.show("正在发送,过程可能比较缓慢...");
	$.ajax({
		type:		"post",
		dataType:	"json",
		data:		"ToMailList="+escape($("#txtToMailList").val())+"&Title="+escape($("#txtTitle").val())+"&Body="+escape($("#txtBody").val()),
		url:		"ajax.aspx?oper=sendmail&time="+(new Date().getTime()),
		error:		function(XmlHttpRequest,textStatus, errorThrown){top.JumbotCms.Loading.hide();alert(XmlHttpRequest.responseText); },
		success:	function(d){
			switch (d.result)
			{
			case '-1':
				top.JumbotCms.Alert(d.returnval, "0", "top.window.location='" + site.Dir + "admin/login.htm';");
				break;
			case '0':
				top.JumbotCms.Alert(d.returnval, "0");
				break;
			case '1':
				top.JumbotCms.Alert(d.returnval, "1");
				break;
			}
		}
	});
}
</script>
</head>
<body>
<form id="sendmailForm" name="form1" method="post" action="ajax.aspx?oper=sendmail">
	<table class="formtable">
		<tr>
			<th> 收件人列表 </th>
			<td><textarea onblur="FormatMailList('txtToMailList');" name="txtToMailList" id="txtToMailList" style="height:40px;width:97%;" class="ipt"></textarea>
				<div class="ValidatorTip" id="tipToMailList" style="width:150px;"></div>
				
				
			</td>
		</tr>
		<tr>
			<th> 邮件标题 </th>
			<td><input name="txtTitle" type="text" id="txtTitle" style="width:97%;" class="ipt" />
				<div class="ValidatorTip" id="tipTitle" style="width:150px"></div></td>
		</tr>
		<tr>
			<th> 邮件内容 </th>
			<td><Jumbot:Editor id="txtBody" runat="server" Width="97%" Toolbar="Simple"></Jumbot:Editor>
			</td>
		</tr>
	</table>
	<div class="buttonok">
		<input type="submit" value="发送" id="btnSaveContent" class="btnsubmit" />
	</div>
</form>
</body>
</html>
